<template>
	<view class="userinfo" :style="{marginTop: `${navHeight+navTop+21}px`}">
		<view class="left">Hi~ {{userInfo.userName ?? '微信用户'}}</view>
		<view class="right">
			<view v-if="!personalStore.vip" class="tip" @click="openvipBtn">成为会员</view>
			<image class="img" :src="userInfo.headPortrait ?? '../../../../static/1f6b11dbc607ddce.jpg'" mode="widthFix">
			</image>
		</view>
	</view>
</template>

<script setup>
	import useMenuButton from '@/hook/use-menu-button';

	import {
		usePersonalStore
	} from '../../../../store/index.js'

	const personalStore = usePersonalStore()

	// 获取胶囊信息
	const [navHeight, navTop] = useMenuButton()

	defineProps({
		userInfo: {
			type: Object,
			default: () => ({})
		}
	})

	const openvipBtn = () => {
		uni.navigateTo({
			url: '/pages/open-vip/open-vip'
		})
	}
</script>

<style lang="scss">
	.userinfo {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 30rpx 0;

		.left {
			font-size: 32rpx;
		}

		.right {
			display: flex;
			align-items: center;

			.tip {
				font-size: 24rpx;
				color: $text-color;
				background-color: #F7FBFE;
				padding: 10rpx 22rpx;
				padding-right: 10rpx;
				border-radius: 30rpx 0 0 30rpx;
				position: relative;
				left: 6rpx;
			}

			.img {
				width: 90rpx;
				height: 90rpx;
				border-radius: 50%;
				z-index: 99;
				box-shadow: 0 8rpx 28rpx rgba(0, 0, 0, 0.5);
			}
		}
	}
</style>